package com.pearl.nacos.config.demo.config;

import com.alibaba.cloud.nacos.NacosConfigManager;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;


/**
 *
 * @author TD
 * @version 1.0
 * @date 2024/4/25
 */
public class ShardingSphereSpringApplicationRunListener implements ApplicationListener<ContextRefreshedEvent> {

    /**
     * 环境准备完成时
     */
    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        ApplicationContext applicationContext = event.getApplicationContext();
        NacosConfigManager nacosConfigManager = applicationContext.getBean(NacosConfigManager.class);
        NacosConfigManagerUtils.init(nacosConfigManager);
    }
}
